package org.hongzhisoft.dis.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hongzhisoft.dis.service.RoleService;
import org.hongzhisoft.dis.service.impl.RoleServiceImpl;

/**
 * 角色删除操作处理类
 * @author HongChengzhi
 *
 */
@WebServlet("/role/delete")
public class RoleDeleteServlet extends HttpServlet {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private RoleService roleService = new RoleServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {

        int role_id =  Integer.parseInt(req.getParameter("role_id"));
        String role_name =  req.getParameter("role_name");

        try {
             roleService.deleteRole(role_id);
             req.setAttribute("role_name", role_name);
             req.getRequestDispatcher("/deleterole_success.jsp").forward(req, resp);
             
        } catch (Exception e) {
            throw new ServletException(e);
        }
        


    }

}
